<template>
    <div class="login">
        <el-container>
            <el-header>千为登录模板</el-header>
            <el-main class="center-center">
                <el-form :model="ruleForm2" status-icon ref="ruleForm2" label-width="100px" class="demo-ruleForm">
                    <el-form-item label="账号" prop="account">
                        <el-input v-model="ruleForm2.account" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="密码" prop="password">
                        <el-input type="password" v-model="ruleForm2.password" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="验证码" prop="password">
                        <el-input type="password" v-model="ruleForm2.captcha" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="submitForm('ruleForm2')">登录</el-button>
                        <el-button @click="resetForm('ruleForm2')">注册</el-button>
                    </el-form-item>
                </el-form>
            </el-main>
            <el-footer>底部标识</el-footer>
        </el-container>
    </div>
</template>
<script>
export default{
    data(){
        return{
            ruleForm2: {
                account: '17791351817',
                password: 'aaaaaa',
                captcha:''
            },
        }
    },
    created(){
        window.this=this;
    },
    methods:{
        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
            if (valid) {
              /*adminAccount:this.adminAccount,account:this.comAccount,password:this.comPwd,captcha:this.captcha*/
                this.$axios.post("signin",{account:this.ruleForm2.account,password:this.ruleForm2.password,captcha:this.ruleForm2.captcha},"formData").then((data)=>{
                    if(data.status==200){
                        window.localStorage.setItem("api_token",data.content.accessToken[0]);
                        this.router.push({path:"/user"});
                    }
                }).catch(function(err){
                    console.log(err);
                })
            } else {
                console.log('error submit!!');
                return false;
            }
            });
        },
    }
}
</script>
<style scoped>
 .el-container.is-vertical{
     height:100%
 }
 .el-header, .el-footer {
    color: #333;
    text-align: center;
    line-height: 60px;
  }

  .el-aside {
    color: #333;
    text-align: center;
    line-height: 200px;
  }

  .el-main {
    color: #333;
    text-align: center;
    background-color: #EFEFEF;
    position: relative;
    /*background: url("../assets/img/bg.jpg");*/
  }
  .login{
      height:100vh;
  }
  .login-form{
      position: absolute;
      top: 5vh;
      width: 500px;
      height:400px;
      background-color: #000;
  }

</style>
